package cn.diancan.vo.other;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * 分享的内容。(先放着,以后再看要不要弄成表)
 * @author Sky
 *
 */
public class ShareTextVo {
    
    private static Map<Integer ,ShareTextVo> map = new HashMap<Integer ,ShareTextVo>();

    //{userId}  //租号
    //{price}	//价格
    //{nick}    //昵称
    static{
	map.put(1,new ShareTextVo(1,1,"以时间变金钱，还不玩最炫应用“租我”就OUT了！"));
	map.put(2,new ShareTextVo(2,1,"你猜“租我”需要多少钱！"));
	map.put(3,new ShareTextVo(3,1,"要“租我”,上“租我”.即能打发时间又能赚钱！"));
	map.put(4,new ShareTextVo(4,1,"你“租我”一次时间，我还你一生幸福！"));
	map.put(5,new ShareTextVo(5,1,"请牢记“租我”号：{userId},随时可来“租我”！"));
	map.put(6,new ShareTextVo(6,1,"今天有空，可以“租我”！小伙伴们请多多关照！"));
	map.put(7,new ShareTextVo(7,1,"{nick}正在出租自已，小伙伴们！GO！"));
	map.put(8,new ShareTextVo(8,1," 只需￥{price}元，你就可以来“租我”啦！"));
	map.put(9,new ShareTextVo(9,1,"其实“出租自已”不为钱，只要合得来就行！"));
	map.put(10,new ShareTextVo(10,1,"“租我”啦！为你办事，24小时为你服务！"));
	map.put(11,new ShareTextVo(11,1,"我想把自已租出去?你如想租就来“租我”啦"));
    }
    
    private Integer sharetextId;  //内容id
    private Integer shareTypeId;  //分类id
    private String  text;	  //内容
    
    private ShareTextVo(Integer sharetextId,Integer shareTypeId, String text) { 
	this.sharetextId = sharetextId;
	this.shareTypeId=shareTypeId;
	this.text = text;
    }
    
    public ShareTextVo(){
	
    }
    
    
    public Integer getSharetextId() {
        return sharetextId;
    } 
    public void setSharetextId(Integer sharetextId) {
        this.sharetextId = sharetextId;
    }


    /*public Integer getShareTypeId() {
        return shareTypeId;
    }
    public void setShareTypeId(Integer shareTypeId) {
        this.shareTypeId = shareTypeId;
    }*/
    public String getText() {
        return text;
    }
    public void setText(String text) {
        this.text = text;
    } 

    public static ShareTextVo findRandom(Integer shareTypeId ){
	Integer key = new Random().nextInt(map.size())+1; 
	return map.get(key);
    }
   
    
    public static ShareTextVo findByshareTextId(Integer shareTypeId,String userId,String nick,String price){
	if(null==shareTypeId){
	    shareTypeId=1;
	}
	ShareTextVo vo= new ShareTextVo();
	ShareTextVo vo2 =map.get(shareTypeId); 
	if(null==vo2){
	    vo2 = map.get(1);
	}
	
	vo.setSharetextId(vo2.getSharetextId());
	vo.setText(vo2.getText());
	
	userId= null==userId?"":userId;
	nick= null==nick?"":nick;
	price= null==price?"":price; 
	
	String text = vo.getText();
	text=text.replace("{userId}", userId);
	text=text.replace("{nick}", nick);
	text=text.replace("{price}", price);
	vo.setText(text);
	return vo;
    } 
    
    
}
